package com.atguigu.gulimall.auth;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;

/**
 * @EnableDiscoveryClient   服务注册发现客户端
 * @EnableFeignClients      远程调用
 * @EnableRedisHttpSession  整合Redis作为Session存储
 *
 * Spring Session核心原理
 * @EnableRedisHttpSession导入了RedisHttpSessionConfiguration配置
 *      1.给容器中添加了一个组件
 *          SessionRepository==>>>[RedisIndexedSessionRepository]==>redis操作session的增删改查的封装类
 *      2.SessionRepositoryFilter==>Filter:  session存储过滤器->每个请求过来都必须经过Filter
 *          2.1.创建的时候就自动从容器中获取到了SessionRepository
 * 核心:    2.2.doFilterInternal,原始的request,response都被包装,SessionRepositoryRequestWrapper,SessionRepositoryResponseWrapper
 *               包装原始请求对象:SessionRepositoryFilter<S>.SessionRepositoryRequestWrapper wrappedRequest = new SessionRepositoryFilter.SessionRepositoryRequestWrapper(request, response);
 *               包装原始响应对象:SessionRepositoryFilter.SessionRepositoryResponseWrapper wrappedResponse = new SessionRepositoryFilter.SessionRepositoryResponseWrapper(wrappedRequest, response);
 *               将包装后的对象应用到了后面的整个执行链:filterChain.doFilter(wrappedRequest, wrappedResponse);
 *          2.3.以后获取session,request.getSession();
 *          2.4.wrappedRequest.getSession()===>SessionRepository中获取到的
 * 装饰者模式
 *      自动延期:redis中的数据也是有过期时间的
 */
@EnableFeignClients
@EnableDiscoveryClient
@EnableRedisHttpSession
@SpringBootApplication
public class GulimallAuthServerApplication {

    public static void main(String[] args) {
        SpringApplication.run(GulimallAuthServerApplication.class, args);
    }

}
